# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=direnv
pkgver=2.32.1
pkgrel=0
pkgdesc="Environment variable switcher for the shell"
url="https://direnv.net"
license="MIT"
arch="all"
depends="bash"
makedepends="go"
subpackages="$pkgname-doc $pkgname-fish::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/direnv/direnv/archive/v$pkgver.tar.gz"

export GOMODCACHE="$srcdir/go"
export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	make GO_BUILD_FLAGS="-ldflags='-s -w'"
}

check() {
	# Also has tests for tcsh and elvish, this manual call is done instead of
	# tests to avoid unwanted tests like 'shellcheck' and 'go-fmt'
	make test-go test-bash
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr install
}

fish() {
	pkgdesc="configuration hooks for fish"
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	amove usr/share/fish/vendor_conf.d
}

sha512sums="
1d4f7f4ef8ff4c84e6a5f0cb2cbd510064b7d0c9de41f57b075024af06407fe0cc40ddcd9f6f52ca260550833e38ae9690b39abc85e17a3c500899ec46f761e4  direnv-2.32.1.tar.gz
"
